package cn.afterturn.svn.analysis.service.historyinfo;

import java.util.List;

import org.nutz.dao.QueryResult;
import org.nutz.dao.pager.Pager;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.service.IdEntityService;

import cn.afterturn.svn.analysis.entity.historyinfo.HistoryInfoEntity;
import cn.afterturn.svn.analysis.service.historypath.HistoryPathService;
import cn.afterturn.svn.analysis.service.userinfo.UserInfoService;

/**
 *  历史服务
 * @author JueYue
 * @date 2015-07-29 15:39
 * @version V1.0  
 **/
@IocBean(name = "historyInfoService", fields = { "dao" })
public class HistoryInfoService extends IdEntityService<HistoryInfoEntity> {

    @Inject
    private HistoryPathService historyPathService;

    @Inject
    private UserInfoService userInfoService;

    private static final Log log = Logs.get();

    /**
     * 批量保存信息
     * @param list
     */
    public void batchSaveHistoryInf(List<HistoryInfoEntity> list) {
        HistoryInfoEntity e;
        for (int i = 0; i < list.size(); i++) {
            e = list.get(i);
            //检查这个用户有没有加入用户表
            userInfoService.checkUser(e.getAuthor(), e.getDate());
            
            dao().insert(e);
            //保存修改详情
            historyPathService.batchSaveHistoryPath(e.getPaths(), e);
        }
    }


    public QueryResult getHistoryInfoPage(HistoryInfoEntity entity, Pager pager) {
        return null;
    }

}
